package org.agony2d.gpu.core {
	import flash.display3D.IndexBuffer3D;
	import flash.display3D.VertexBuffer3D;
	import flash.utils.ByteArray;
	import flash.utils.Endian;
	import org.agony2d.core.agony_internal;
	
	use namespace agony_internal;
	
final public class VertexConvergence extends VertexProxy {
	
	agony_internal function updateTotalAndIndexList() : void {
		m_totalNodes = this.bytes.length / BYTES_PER_NODE
		if (m_totalNodes > m_maxNodes) {
			m_indexList.fixed = false
			while (m_totalNodes > m_maxNodes) {
				m_indexList[m_maxNodes * NUM_INDEX_PER_NODE]      =  0 + m_maxNodes * NUM_VERTEX_PER_NODE
				m_indexList[m_maxNodes * NUM_INDEX_PER_NODE + 1]  =  1 + m_maxNodes * NUM_VERTEX_PER_NODE
				m_indexList[m_maxNodes * NUM_INDEX_PER_NODE + 2]  =  2 + m_maxNodes * NUM_VERTEX_PER_NODE
				m_indexList[m_maxNodes * NUM_INDEX_PER_NODE + 3]  =  1 + m_maxNodes * NUM_VERTEX_PER_NODE
				m_indexList[m_maxNodes * NUM_INDEX_PER_NODE + 4]  =  2 + m_maxNodes * NUM_VERTEX_PER_NODE
				m_indexList[m_maxNodes * NUM_INDEX_PER_NODE + 5]  =  3 + m_maxNodes * NUM_VERTEX_PER_NODE
				m_maxNodes++
			}
			m_indexList.fixed = true
		}
	}
	
	agony_internal function reset() : void {
		this.bytes.length = m_totalNodes = 0
	}
	
	
	agony_internal static const NUM_INDEX_PER_NODE:int = 6
	
	agony_internal var m_indexList:Vector.<uint> = new <uint>[]
	agony_internal var m_maxNodes:int
	agony_internal var m_totalNodes:int
}
}